﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AsterNET.FastAGI.Command;

namespace AsterNET.Extensions.FastAGI.Helpers
{

    public class MixMonitorOptions
    {
        public static string OnlyWhenBridged()
        {
            return "b";
        }
        public static string AppendToFile()
        {
            return "a";
        }

        public static string AdjustHeardVolume(int byFactor)
        {
            return string.Format("v({0})", byFactor);
        }
        public static string AdjustSpokenVolume(int byFactor)
        {
            return string.Format("V({0})", byFactor);
        }
        public static string AdjustOverallVolume(int byFactor)
        {
            return string.Format("W({0})", byFactor);
        }

    }

    public class MixMonitorHelper
    {
        /// <summary>
        /// Records The audio on the current channel to the specified file.
        /// </summary>
        /// <param name="filename">Filename to save the channel audio too, including the file extension (filename.ext)</param>
        /// <param name="command">Will be executed when the recording is over. Any strings matching ^{X} will be unescaped to ${X} and all variables will be evaluated at the time the application is called. Where <command> is a system (Linux shell) command, see Asterisk cmd System for example values.</param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static ExecCommand MixMonitor(string filename, string command = null, params string[] options)
        {
            string rtn;
            var opts = String.Join(",", options);
            if (command == null)
                rtn = string.Format("{0},{1}",
                    filename, opts);
            else
                rtn = string.Format("{0},{1},{2}",
                    filename, opts, command);

            return new ExecCommand("MixMonitor", rtn);
        }

    }
}
